//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class ColorMapping : IOfficeXmlSerializableAs
    {
        private ColorSchemeIndex accent1;
        private ColorSchemeIndex accent2;
        private ColorSchemeIndex accent3;
        private ColorSchemeIndex accent4;
        private ColorSchemeIndex accent5;
        private ColorSchemeIndex accent6;
        private ColorSchemeIndex bg1;
        private ColorSchemeIndex bg2;
        private ColorSchemeIndex folHlink;
        private ColorSchemeIndex hlink;
        private ColorSchemeIndex tx1;
        private ColorSchemeIndex tx2;

        public ColorSchemeIndex Background1
        {
            get { return bg1; }
            set { bg1 = value; }
        }

        public ColorSchemeIndex Text1
        {
            get { return tx1; }
            set { tx1 = value; }
        }

        public ColorSchemeIndex Background2
        {
            get { return bg2; }
            set { bg2 = value; }
        }

        public ColorSchemeIndex Text2
        {
            get { return tx2; }
            set { tx2 = value; }
        }

        public ColorSchemeIndex Accent1
        {
            get { return accent1; }
            set { accent1 = value; }
        }

        public ColorSchemeIndex Accent2
        {
            get { return accent2; }
            set { accent2 = value; }
        }

        public ColorSchemeIndex Accent3
        {
            get { return accent3; }
            set { accent3 = value; }
        }

        public ColorSchemeIndex Accent4
        {
            get { return accent4; }
            set { accent4 = value; }
        }

        public ColorSchemeIndex Accent5
        {
            get { return accent5; }
            set { accent5 = value; }
        }

        public ColorSchemeIndex Accent6
        {
            get { return accent6; }
            set { accent6 = value; }
        }

        public ColorSchemeIndex Hyperlink
        {
            get { return hlink; }
            set { hlink = value; }
        }

        public ColorSchemeIndex FollowedHyperlink
        {
            get { return folHlink; }
            set { folHlink = value; }
        }

        #region IOfficeXmlSerializable Members

        void IOfficeXmlSerializableAs.ReadXmlAs(string name, ReadContext context)
        {
            using (var c = context.Read(name))
            {
                c.WarnIf("extLst");
                Background1 = c.GetEnum<ColorSchemeIndex>("bg1");
                Text1 = c.GetEnum<ColorSchemeIndex>("tx1");
                Background2 = c.GetEnum<ColorSchemeIndex>("bg2");
                Text2 = c.GetEnum<ColorSchemeIndex>("tx2");
                Accent1 = c.GetEnum<ColorSchemeIndex>("accent1");
                Accent2 = c.GetEnum<ColorSchemeIndex>("accent2");
                Accent3 = c.GetEnum<ColorSchemeIndex>("accent3");
                Accent4 = c.GetEnum<ColorSchemeIndex>("accent4");
                Accent5 = c.GetEnum<ColorSchemeIndex>("accent5");
                Accent6 = c.GetEnum<ColorSchemeIndex>("accent6");
                Hyperlink = c.GetEnum<ColorSchemeIndex>("hlink");
                FollowedHyperlink = c.GetEnum<ColorSchemeIndex>("folHlink");
            }
        }

        void IOfficeXmlSerializableAs.WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                c.WarnIf("extLst");
                c.SetEnum("bg1", Background1);
                c.SetEnum("tx1", Text1);
                c.SetEnum("bg2", Background2);
                c.SetEnum("tx2", Text2);
                c.SetEnum("accent1", Accent1);
                c.SetEnum("accent2", Accent2);
                c.SetEnum("accent3", Accent3);
                c.SetEnum("accent4", Accent4);
                c.SetEnum("accent5", Accent5);
                c.SetEnum("accent6", Accent6);
                c.SetEnum("hlink", Hyperlink);
                c.SetEnum("folHlink", FollowedHyperlink);
            }
        }

        #endregion
    }
}